package quantum2;

import quantum2.graph.Graph;
import quantum2.graph.Matrix;
import quantum2.graph.Schedule;
import quantum2.graph.StatResult;
import quantum2.math.Arithmetic;
import quantum2.math.Complex;

public class Test {

    public static void main(String[] args) {
        Graph g = new Graph(1, Math.sqrt(2));
        Arithmetic a = Arithmetic.createArithmetic(1e-10);
        Matrix matrix = new Matrix(Complex.number(2), Complex.number(1), Complex.number(2), Complex.number(1));
        Schedule schedule = new Schedule(g, a, matrix);
        long t0 = System.currentTimeMillis();
        schedule.schedule(0.0, Complex.rect(1, 0), Graph.E_BS, true);
        while (true) {
            double time = schedule.getCurrentTime();
            if (time >= 10000)
                break;
            schedule.next();
        }
        System.out.println("Real time: " + (System.currentTimeMillis() - t0));
        StatResult stat = schedule.getStat();
        System.out.println("Total energy: " + stat.totalEnergy);
        for (int i = 0; i < g.getEdgeNum(); i++) {
            double e = stat.edgeEnergy[i];
            double num = stat.edgeNum[i];
            double edgeLength = g.getEdgeLength(i).doubleValue();
            System.out.println("Energy " + i + ": " + e / edgeLength);
            System.out.println("Num " + i + ": " + num / edgeLength / stat.numPhotons);
        }
        System.out.println("Time: " + stat.currentTime + ", Number: " + stat.numPhotons);
    }
}
